package com.blog.mapper;

import com.blog.entity.comment.Comment;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface CommentMapper {

    @Select("select COUNT(*) from comments where uid = #{uid}")
    Integer getCommentCountByUid(Integer uid);

    @Select("select * from comments where aid = #{aid}")
    List<Comment> getCommentsByAid(Integer aid);

    @Insert("insert into comments(aid, uid, content) values(#{aid}, #{uid}, #{content})")
    Integer addComment(Comment comment);

    @Delete("delete from comments where cid = #{cid}")
    Integer deleteComment(Integer cid);
}
